<template>
    <!-- 消防报表详情 -->
    <div class="fire-report-detail">
        <iframe width="100%" height="100%" v-if="reportUrl != ''" :src="reportUrl"></iframe>
    </div>
</template>
<script>
export default {
    name: "FireReportDetail",
    props: ["reportAttr"],
    data() {
        return {
            staticPath:'',
            reportUrl: ''
        }
    },
    created() {
        let isDev=location.href.indexOf('localhost:')>-1
        let hostport=location.origin;//ip:端口号
        this.staticPath = isDev?('http://localhost:8889/pages/apply/reportTemplate/'):(hostport + '/ilink-app-h5-zd/pages/apply/reportTemplate/')
        let obj = this.reportAttr
        let centerPath = ''

        if(obj.period == 1 && obj.isUnit == 0) {
            centerPath = 'regulatorWeekly'
        } else if (obj.period == 1 && obj.isUnit == 1) {
            centerPath = 'singleWeekly'
        } else if (obj.period == 3) {
            centerPath = 'yearReport'
        } else if (obj.period == 4) {
            centerPath = 'platformReport'
        }

        // 2020年（包括）之后的年报使用新地址
        let year=obj.startTime.split('-')[0]
        if(obj.period==2||obj.period==5){
            let routePah=obj.isUnit==1?'UnitReport':'PlatformReport'
            this.reportUrl=`${isDev?'http://localhost:3001/#/':'/ilink-app-h5-zd/ilink-zhxf-h5/#/'}${routePah}?reportId=${obj.id}&period=${obj.period}`
        }
        else if((obj.period==3||obj.period==4)&&year>2019){
            let routePah=`/YearReport${obj.period==3?'Unit':'Platform'}`
            this.reportUrl=(isDev?'http://localhost:3001/#':'/ilink-app-h5-zd/ilink-zhxf-h5/#')+routePah+'?reportId='+obj.id
        }else{
            this.reportUrl = this.staticPath + centerPath + '.html?reportId=' + obj.id;
        }
    }
}
</script>
<style lang="scss">
.fire-report-detail {
    position: relative;
    width: 100%;
    height: 800px;
}
</style>
